*****************************************************************************
*********            Appendix Table G9 - Homogeneous Agent, Without Reliability
*****************************************************************************
local cutoff=0.01
clear




// FULL SAMPLE NO RELIABILITY AND E(TT)




clear
save ".\data\temp\temp1", replace emptyok

* Get reliability
*I 10 W
use ".\data\clean\HV_ML_reliab", clear
keep if fwy==10&dir=="W"
format date %d
sort date hour
tempfile temp2
save `temp2'


use ".\data\clean\I10W_laneuse_dataset_15nov14_wcensus", clear

sort date hour
merge m:1 date hour using `temp2', keep(1 3) nogen 
drop if weekend==1
keep if inlist(hour,5,6,7,8)
drop if holiday==1

*WTP calculation
gen EL_TT=dist/ELspeed
gen ML_TT=dist/MLspeed
gen MP=inlist(hour,5,6,7,8)&weekend==0
gen TT_dif_hr=ML_TT-EL_TT
gen WTP2=charged_toll/TT_dif_hr



gen reliabilityML=dist/p20_speedML-dist/p50_speedML
gen reliabilityHV=dist/p20_speedHV-dist/p50_speedHV
gen reliability_diff=reliabilityML-reliabilityHV
replace reliability_diff=0 if reliability_diff<`cutoff'
keep if WTP2>0&WTP2~=.
keep if reliability_diff~=.
drop if TT_dif_hr==.
keep if acct_type=="PRIVATE"&occupancy~="HOV-3"
egen id=group(date rt_id)
egen tid=group(date hour rt_id)
egen acctid=group(acct_no)
duplicates drop acctid entry_time, force
xtset acctid entry_time

*******************************************************************************
***			 Column I --- Full Sample Homog. Agent 					*******
*******************************************************************************
keep if TT_dif_hr>0 
gen count=1
egen freq=sum(count), by(acct_no)
drop if freq<2
drop freq count




reg charged_toll TT_dif_hr reliability_diff if TT_dif_hr>0  
est sto b0

reg charged_toll TT_dif_hr  if TT_dif_hr>0 
est sto b1

suest b0 b1, cluster(rt_id)
test [b0_mean]_cons=[b1_mean]_cons
local c_chow=round(`r(p)',.01)
test [b0_mean]TT_dif_hr=[b1_mean]TT_dif_hr
local tt_chow=round(`r(p)',.01)

reg charged_toll TT_dif_hr reliability_diff if TT_dif_hr>0 , cluster(rt_id) 
est sto a0
reg charged_toll TT_dif_hr  if TT_dif_hr>0 , cluster(rt_id) 
est sto a1
estadd scalar c_chow=`c_chow'
estadd scalar tt_chow=`tt_chow'




esttab  a0 a1 a2 a3 using ".\results\appendix\tabs\ATCQQQ.csv", replace  ///
	cells(b(star fmt(%9.3f)) se(par)) star(* 0.10 ** 0.05 *** 0.01) ///
	stats(r2 N c_chow tt_chow,fmt(%9.2f %9.0g %9.2f %9.2f %9.2f) ///
		labels(R-squared N Chow_const Chow_TT)) ///
	title("Table C.X--FE Models")  ///
	 nonumbers nodepvars ///
	 order( _cons _Ihour* TT_dif_hr* reliability_diff) label
